//
//  SJBaseTableViewController.swift
//  SJWeiboSwift
//
//  Created by app;e on 15/9/30.
//  Copyright © 2015年 world. All rights reserved.
//
//  各个模块 公共 的父类

import UIKit

class SJBaseTableViewController: UITableViewController,SJUserLoginViewDelegate {

    //用户视图view
    var userLoginView: SJUserLoginView?
    //判断用户是否登陆   userAccount是否为空
    var userLogin = sharedUserAccount != nil
    //实现用户登陆前与登陆后显示不同的界面
    override func loadView() {
        //登陆了显示原来的界面, 没有登陆显示另外的界面
        userLogin ? super.loadView() : setupUserView()
        
    }
    
     func setupUserView(){
        //创建用户视图view
        userLoginView = SJUserLoginView()
        userLoginView?.delegate = self
         view = userLoginView!

        //添加导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "userLoginViewLoginBtnDidClick")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "userLoginViewRegisterBtnDidClick")
    
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    
    }

    ///SJUserLoginViewDelegate
    func userLoginViewLoginBtnDidClick() {
        //跳转到授权界面
        let vc = SJOAuthViewController()
        let nav = UINavigationController(rootViewController: vc)
        
        presentViewController(nav, animated: true, completion: nil)
        
//        print("login")
    }
    func userLoginViewRegisterBtnDidClick() {
        print("register")
    }
}
